<?php
class CitiesController extends AppController{

	//var $uses = Array("Company","City","User","Group");

	/**
	 * Lista na gradovite
	 * @return void
	 */
	public function index(){
		
		$this->set('cities',$this->City->find("all"));
		
	}
	
	/**
	 * Kreira nov zapis za grad
	 * @return void
	 */
	public function create(){
		
		if(!empty($this->data)){
			
			if($this->City->save($this->data)){
				$this->flash("City created","/cities",2);
			}			
		}
	}
	
	/**
	 * Detali za gradot
	 * Lista na opshtini, oblasti
	 * @return void
	 */
	public function details(){
		
		if(!empty($this->params['named']['city'])){
			$conditions = array("City.id" => $this->params['named']['city']);		
			$city = $this->City->find('first', array('conditions' => $conditions));		
			$this->set('city',$city);
		}else{
			$this->redirect("/cities");	
		}
	}
}